#define _CRT_SECURE_NO_WARNINGS

#include <chrono>
#include <iostream>
#include <string>
using namespace std;

int main() {
    int n;
    cin >> n;
    string command;
    cin >> command;

    int left = 1, right = 4, ptr = 1;
    for (auto& e : command)
    {
        if (e == 'U')
        {
            if (ptr == 1)
            {
                ptr = n;
                left = n - 3;
                right = n;
            }
            else
            {
                ptr--;
                if (ptr < left)
                {
                    left--;
                    right--;
                }
            }
        }
        else
        {
            if (ptr == n)
            {
                ptr = 1;
                left = 1;
                right = 4;
            }
            else
            {
                ptr++;
                if (ptr > right)
                {
                    left++;
                    right++;
                }
            }
        }
    }

    for (int i = max(0, left); i <= min(n, right); i++)
        cout << i << " ";
    cout << endl << ptr << endl;

    return 0;
}